<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
  <head th:fragment="html_head">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />

    <script
      type="text/javascript"
      th:src="@{/webjars/jquery/jquery.min.js}"
    ></script>
    <script
      type="text/javascript"
      th:src="@{/webjars/bootstrap/js/bootstrap.min.js}"
    ></script>
    <script type="text/javascript" th:src="@{/js/functions.js}"></script>

    <link
      rel="stylesheet"
      type="text/css"
      th:href="@{/webjars/font-awesome/css/all.css}"
    />
    <link
      rel="stylesheet"
      type="text/css"
      th:href="@{/webjars/bootstrap/css/bootstrap.min.css}"
    />
    <link rel="stylesheet" type="text/css" th:href="@{/css/style.css}" />

    <title>[[${pageTitle}]] | ShopWise Admin Control Panel</title>
  </head>
  <head th:fragment="html_head_reduced">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />

    <link
      rel="stylesheet"
      type="text/css"
      th:href="@{/webjars/bootstrap/css/bootstrap.min.css}"
    />
    <link rel="stylesheet" type="text/css" th:href="@{/css/style.css}" />

    <title>[[${pageTitle}]] | ShopWise Admin Control Panel</title>
  </head>
  <body>
    /* Begin Pagination Fragment */
    <div th:fragment="pagination(moduleURL, entityName)">
      <div class="text-center m-1" th:if="${totalCount > 0}">
        <span
          >[[${entityName}]] # [[${startCount}]] to [[${endCount}]] of
          [[${totalCount}]]</span
        >
      </div>
      <div class="text-center m-1" th:unless="${totalCount > 0}">
        <span>No [[${entityName}]] found</span>
      </div>
      <div th:if="${totalPages > 1}">
        <nav>
          <ul class="pagination justify-content-center flex-wrap">
            <li
              th:class="${currentPage > 1 ? 'page-item' : 'page-item disabled'}"
            >
              <a
                th:replace="fragments_pagination :: pagination_link(${moduleURL}, 1, 'First')"
              ></a>
            </li>
            <li
              th:class="${currentPage > 1 ? 'page-item' : 'page-item disabled'}"
            >
              <a
                th:replace="fragments_pagination :: pagination_link(${moduleURL},${currentPage - 1}, 'Previous')"
              ></a>
            </li>
            <li
              th:class="${currentPage != i ? 'page-item' : 'page-item active'}"
              th:each="i : ${#numbers.sequence(1, totalPages)}"
            >
              <a
                th:replace="fragments_pagination :: pagination_link(${moduleURL},${i}, ${i})"
              ></a>
            </li>
            <li
              th:class="${currentPage &lt; totalPages ? 'page-item' : 'page-item disabled'}"
            >
              <a
                th:replace="fragments_pagination :: pagination_link(${moduleURL},${currentPage + 1}, 'Next')"
              ></a>
            </li>
            <li
              th:class="${currentPage &lt; totalPages ? 'page-item' : 'page-item disabled'}"
            >
              <a
                th:replace="fragments_pagination :: pagination_link(${moduleURL}, ${totalPages}, 'Last')"
              ></a>
            </li>
          </ul>
        </nav>
      </div>
    </div>

    /* Begin Pagination Link (a) */
    <a
      th:fragment="pagination_link(moduleURL, pageNumber, label)"
      class="page-link"
      th:href="@{${moduleURL} + '/page/' + ${pageNumber} +  '?sortField=' + ${sortField} + '&sortDirection=' + ${sortDirection} + ${keyword != null ? '&keyword=' + keyword : ''}}"
    >
      [[${label}]]
    </a>

    /* End Pagination Link (a) */ /* End Pagination Fragment */
  </body>
</html>
